package com.linkin.homepage.util

import android.content.Context
import java.io.BufferedReader
import java.io.InputStreamReader

class AssetUtil {

    companion object {

        @Throws
        fun getAssetJsonFile(context: Context): String {
            val assetManager = context.assets
            val inputStream = assetManager.open("HomePageJson.json")

            val inputReader = InputStreamReader(inputStream)
            val stringBuilder = StringBuilder()

            BufferedReader(inputReader).use {
                var line: String?
                while (true) {
                    line = it.readLine() ?: break //当有内容时读取一行数据，否则退出循环
                    stringBuilder.append(line)
                }
            }
            return stringBuilder.toString()
        }
    }

}